home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / contro3r / gamestuf.bas < prev    next >
BASIC Source File  |  1998-06-20  |  5KB  |  159 lines

  1. Attribute VB_Name = "GAMESTUFF"
  2. Option Explicit
  3.  
  4. Public Type TankSettings
  5.     Angle As Integer
  6.     Power As Integer
  7. End Type
  8.  
  9. Public Type OPair
  10.     x As Double
  11.     y As Double
  12. End Type
  13.  
  14. Public Declare Function FloodFill Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
  15. Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
  16. Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
  17.  
  18. Public Const SND_SYNC = &H0
  19. Public Const SND_ASYNC = &H1
  20. Public Const PNT = &HCC0020
  21.  
  22. Global Const TURN_RED = False
  23. Global Const TURN_BLUE = True
  24. Global Const LLength = 12
  25.  
  26. Global Const GREEN = 65280
  27. Global Const SKY_BLUE = 16776960
  28. Global Const DARK_GRAY = 8224125
  29. Global Const WHITE = 16777215
  30. Global Const RED = 255
  31. Global Const BLUE = 16711680
  32. Global Const ORANGE = 45055
  33.  
  34. Global Const OPENING = "PRESS F2 TO BEGIN A NEW GAME"
  35.  
  36. Global Const BORDER_INSET = 0
  37. Global Const BORDER_RAISED = 1
  38.  
  39. Global Const RT_SCRIPT = "Red's Turn"
  40. Global Const BT_SCRIPT = "Blue's Turn"
  41. Global Const BulVel = 10
  42. Global Const pi = 3.14159265358979
  43.  
  44. Global Const rDieCapt = "Red is destroyed!"
  45. Global Const bDieCapt = "Blue is destroyed!"
  46.  
  47. Public XPos As Double, YPos As Double
  48.  
  49. Public InGame As Boolean
  50. Public InFire As Boolean
  51. Public InPause As Boolean
  52.  
  53. Public BTank As TankSettings, RTank As TankSettings
  54.  
  55. Global Const TxtFire = "FIRE!!!"
  56. Global Const TxtReset = "RESET"
  57.  
  58. Global Const rSndFire = "REDGUN"
  59. Global Const bSndFire = "BLUEGUN"
  60. Global Const rDest = "REDHIT"
  61. Global Const bDest = "BLUEHIT"
  62. Global Const gDest = "GREENHIT"
  63. Global Const Fire = "FIRE"
  64. Global Const Er = "NEGATIVE"
  65.  
  66. Public XSpot As Double, YSpot As Double
  67.  
  68. Public tmpColor As Long
  69.  
  70. Public RTurn As Boolean
  71. Public Mov As OPair
  72. Public BulVis As Boolean
  73.  
  74. Public AppPath As String
  75.  
  76. Sub Make3D(pic As Form, ctl As Control, ByVal BorderStyle As Integer)
  77. Dim AdjustX As Integer, AdjustY As Integer
  78. Dim RightSide As Single
  79. Dim BW As Integer, BorderWidth As Integer
  80. Dim LeftTopColor As Long, RightBottomColor As Long
  81. Dim i As Integer
  82.  
  83.     If Not ctl.Visible Then Exit Sub
  84.  
  85.     AdjustX = Screen.TwipsPerPixelX
  86.     AdjustY = Screen.TwipsPerPixelY
  87.     BorderWidth = 3
  88.     Select Case BorderStyle
  89.     Case 0:
  90.         LeftTopColor = DARK_GRAY
  91.         RightBottomColor = WHITE
  92.     Case 1:
  93.         LeftTopColor = WHITE
  94.         RightBottomColor = DARK_GRAY
  95.     End Select
  96.     For BW = 1 To BorderWidth
  97.         pic.CurrentX = ctl.Left - (AdjustX * BW)
  98.         pic.CurrentY = ctl.Top - (AdjustY * BW)
  99.         pic.Line -(ctl.Left + ctl.Width + (AdjustX * (BW - 1)), ctl.Top - (AdjustY * BW)), LeftTopColor
  100.         pic.Line -(ctl.Left + ctl.Width + (AdjustX * (BW - 1)), ctl.Top + ctl.Height + (AdjustY * (BW - 1))), RightBottomColor
  101.         pic.Line -(ctl.Left - (AdjustX * BW), ctl.Top + ctl.Height + (AdjustY * (BW - 1))), RightBottomColor
  102.         pic.Line -(ctl.Left - (AdjustX * BW), ctl.Top - (AdjustY * BW)), LeftTopColor
  103.     Next
  104. End Sub
  105.  
  106. Sub MIDN()
  107. Dim i%, j%, k&
  108.     i% = Val(Format(Time, "NN"))
  109.     j% = Val(Format(Time, "SS"))
  110.     For k& = 1 To Abs(j% - i%)
  111.         Randomize
  112.     Next k&
  113. End Sub
  114.  
  115. Public Function GetOPair() As OPair
  116. Dim G As TankSettings
  117.     If RTurn = True Then
  118.         G = RTank
  119.     Else
  120.         G = BTank
  121.     End If
  122.     GetOPair.x = Sine(G.Angle) * G.Power
  123.     GetOPair.y = Cosine(G.Angle) * G.Power
  124. End Function
  125.  
  126. Public Function InverseSine(ByVal i As Double) As Double
  127.     InverseSine = Atn(i / Sqr(-i * i + 1))
  128.     InverseSine = InverseSine * (180 / pi)
  129. End Function
  130.  
  131. Public Function Cosine(ByVal i As Double) As Double
  132.     Cosine = Cos(i * (pi / 180))
  133. End Function
  134.  
  135. Public Function Sine(ByVal i As Double) As Double
  136.     Sine = Sin(i * (pi / 180))
  137. End Function
  138.  
  139. Public Sub Wait(ByVal Seconds As Integer)
  140. Dim Start As Double, TotalTime As Double, Finish As Double
  141.     Start = Timer
  142.     Do While Timer < Start + Seconds
  143.         DoEvents
  144.     Loop
  145.     Finish = Timer
  146.     TotalTime = Finish - Start
  147. End Sub
  148.  
  149. Sub Main()
  150.     AppPath = App.Path & "\"
  151.     frmTank.Show vbModal
  152. End Sub
  153.  
  154. Public Sub PlaySound(ByVal File As String)
  155. Dim tFile As String
  156.     tFile = AppPath & File & ".WAV"
  157.     sndPlaySound tFile, SND_ASYNC
  158. End Sub
  159.